import unittest
import json
import requests
class Case(unittest.TestCase):
    headers_one= {'Content-Type': 'application/json; charset=UTF-8'}
    headers_two = {'Content-Type': 'application/json; charset=UTF-8',
               'token': '1-39021-490f461a-1331-4025-9825-c36c7b2d8f24'
               }
    def setUp(self):
        pass
    def tearDown(self):
        pass
    def testopenAPP(self):
        url = 'http://sapi.hcxdi.com/truck/version/update'
        value = {"clientType": 1, "osType": 1, "versionCode": 53}
        data = json.dumps(value)
        response = requests.post(url=url, headers=self.headers_one, data=data)
        #print(response.text)
    def testhomePage(self):
        url = 'http://sapi.hcxdi.com/truck/home/page/driver'
        response = requests.get(url, headers=self.headers_one)
        #print(response.text)
    def testinputPhone(self):
        value = {"username": "15708444813"}
        data = json.dumps(value)
        url = 'http://sapi.hcxdi.com/truck/userDriver/info/query'
        response = requests.post(url=url,headers=self.headers_two, data=data)
        #print(response.text)
    def testinfoCode(self):
        url = 'http://sapi.hcxdi.com/truck/userDriver/validAndGetcode?phone=15708444813&type=0&userId='
        response = requests.get(url, headers=self.headers_one)
        #print(response.text)
    def testLogin(self):
        url = 'http://sapi.hcxdi.com/truck/userDriver/login'
        value = {"code": "6464", "phone": "15708444813", "type": 0, "userId": ""}
        data = json.dumps(value)
        response = requests.post(url=url, headers=self.headers_two, data=data)
        #print(response.text)
    def testoilList(self):
        url = 'http://sapi.hcxdi.com/truck/business/oil/station'
        value = {"currentPage": 1, "lat": 30.551991, "lng": 104.067947, "orgType": 0, "pageSize": 15, "searchType": 1}
        data = json.dumps(value)
        response = requests.post(url=url,headers=self.headers_two, data=data)
        #print(response.text)
    def testchooseOilStation(self):
        url = 'http://sapi.hcxdi.com/truck/business/oil/detail'
        value = {"currentPage": 1, "pageSize": 1, "userId": "27743"}
        data = json.dumps(value)
        response = requests.post(url=url,headers=self.headers_two, data=data)
        #print(response.text)
    def testAddOil(self):
        url = 'http://sapi.hcxdi.com/truck/orgOilGun/codeAndGun'
        value = {"orgId": "2870"}
        data = json.dumps(value)
        response = requests.post(url=url,headers=self.headers_two,data=data)
        #print(response.text)
    def testCreateOrder(self):
        url = 'http://sapi.hcxdi.com/truck/order/create/3.3.1'
        value = {"areaId": 510107, "come": False,
                 "goods": [{"count": 20.0, "id": "8279", "name": "0#柴油", "price": 5.0}], "lat": 30.55212,
                 "lng": 104.068019, "oilGun": "01", "orderAddress": "中国四川省成都市武侯区云华路", "orderType": 14,
                 "repairId": "47541", "status": 0, "truckId": "32698", "userId": "27743"}
        data = json.dumps(value)
        response = requests.post(url=url,headers=self.headers_two, data=data)
        #print(response.text)
    def testOrderPay(self):
        url = 'http://sapi.hcxdi.com/truck/order/pay/create'
        value = {"clientIp": "192.168.249.137", "couponId": "363767", "deviceId": "7e11d22aa850dc53", "id": "139993",
                 "payType": 3, "subject": "加油"}
        data = json.dumps(value)
        response = requests.post(url=url,headers=self.headers_two, data=data)
        #print(response.text)





if __name__ == "__main__":
    unittest.main()